home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / bash_114.zip / bash-1.14.2 / input.h < prev    next >
C/C++ Source or Header  |  1993-12-19  |  4KB  |  114 lines

  1. /* input.h -- Structures and unions used for reading input. */
  2. /* Copyright (C) 1993 Free Software Foundation, Inc.
  3.  
  4.    This file is part of GNU Bash, the Bourne Again SHell.
  5.  
  6.    Bash is free software; you can redistribute it and/or modify it under
  7.    the terms of the GNU General Public License as published by the Free
  8.    Software Foundation; either version 2, or (at your option) any later
  9.    version.
  10.  
  11.    Bash is distributed in the hope that it will be useful, but WITHOUT ANY
  12.    WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13.    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14.    for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License along
  17.    with Bash; see the file COPYING.  If not, write to the Free Software
  18.    Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  19.  
  20. #if !defined (_INPUT_H)
  21. #define _INPUT_H
  22.  
  23. #include "stdc.h"
  24.  
  25. /* Function pointers can be declared as (Function *)foo. */
  26. #if !defined (__FUNCTION_DEF)
  27. #  define __FUNCTION_DEF
  28. typedef int Function ();
  29. typedef void VFunction ();
  30. typedef char *CPFunction ();
  31. typedef char **CPPFunction ();
  32. #endif /* _FUNCTION_DEF */
  33.  
  34. /* Some stream `types'. */
  35. #define st_stream 1
  36. #define st_string 2
  37.  
  38. #if defined (BUFFERED_INPUT)
  39. #define st_bstream 3
  40.  
  41. /* Possible values for b_flag. */
  42. #define B_EOF        0x1
  43. #define B_ERROR        0x2
  44. #define B_UNBUFF    0x4
  45.  
  46. /* A buffered stream.  Like a FILE *, but with our own buffering and
  47.    synchronization.  Look in input.c for the implementation. */
  48. typedef struct BSTREAM
  49. {
  50.   int    b_fd;
  51.   char    *b_buffer;        /* The buffer that holds characters read. */
  52.   int    b_size;            /* How big the buffer is. */
  53.   int    b_used;            /* How much of the buffer we're using, */
  54.   int    b_flag;            /* Flag values. */
  55.   int    b_inputp;        /* The input pointer, index into b_buffer. */
  56. } BUFFERED_STREAM;
  57.  
  58. extern BUFFERED_STREAM **buffers;
  59.  
  60. extern BUFFERED_STREAM *fd_to_buffered_stream ();
  61.  
  62. extern int default_buffered_input;
  63.  
  64. #endif /* BUFFERED_INPUT */
  65.  
  66. typedef union {
  67.   FILE *file;
  68.   char *string;
  69. #if defined (BUFFERED_INPUT)
  70.   int buffered_fd;
  71. #endif
  72. } INPUT_STREAM;
  73.  
  74. typedef struct {
  75.   int type;
  76.   char *name;
  77.   INPUT_STREAM location;
  78.   Function *getter;
  79.   Function *ungetter;
  80. } BASH_INPUT;
  81.  
  82. extern BASH_INPUT bash_input;
  83.  
  84. /* Functions from parse.y. */
  85. extern void initialize_bash_input __P((void));
  86. extern void init_yy_io __P((Function *, Function *, int, char *, INPUT_STREAM));
  87. extern void with_input_from_stdin __P((void));
  88. extern void with_input_from_string __P((char *, char *));
  89. extern void with_input_from_stream __P((FILE *, char *));
  90. extern int push_stream __P((void));
  91. extern int pop_stream __P((void));
  92. extern char *read_secondary_line __P((int));
  93. extern int find_reserved_word __P((char *));
  94. extern char *decode_prompt_string __P((char *));
  95. extern void gather_here_documents __P((void));
  96. extern void execute_prompt_command __P((char *));
  97.  
  98. #if defined (BUFFERED_INPUT)
  99. /* Functions from input.c. */
  100. extern int check_bash_input __P((int));
  101. extern int duplicate_buffered_stream __P((int, int));
  102. extern BUFFERED_STREAM *fd_to_buffered_stream __P((int));
  103. extern BUFFERED_STREAM *open_buffered_stream __P((char *));
  104. extern void free_buffered_stream __P((BUFFERED_STREAM *));
  105. extern int close_buffered_stream __P((BUFFERED_STREAM *));
  106. extern int close_buffered_fd __P((int));
  107. extern int sync_buffered_stream __P((int));
  108. extern int buffered_getchar __P((void));
  109. extern int buffered_ungetchar __P((int));
  110. extern void with_input_from_buffered_stream __P((int, char *));
  111. #endif /* BUFFERED_INPUT */
  112.  
  113. #endif /* _INPUT_H */
  114.